//
//  UIView+Frame.m
//  HotPotNetForMerchant
//
//  Created by shepai on 16/11/3.
//  Copyright © 2016年 SuperDeveloper. All rights reserved.
//

#import "UIView+HZFrame.h"

@implementation UIView (HZFrame)

- (void)setX:(CGFloat)x
{
    CGRect frame = self.frame;
    frame.origin.x = x;
    self.frame = frame;
}

- (CGFloat)x
{
    return self.frame.origin.x;
}

- (void)setY:(CGFloat)y
{
    CGRect frame = self.frame;
    frame.origin.y = y;
    self.frame = frame;
}

- (CGFloat)y
{
    return self.frame.origin.y;
}

- (void)setCenterX:(CGFloat)centerX
{
    CGPoint center = self.center;
    center.x = centerX;
    self.center = center;
}

- (CGFloat)centerX
{
    return self.center.x;
}

- (void)setCenterY:(CGFloat)centerY
{
    CGPoint center = self.center;
    center.y = centerY;
    self.center = center;
}

- (CGFloat)centerY
{
    return self.center.y;
}

- (void)setWidth:(CGFloat)width
{
    CGRect frame = self.frame;
    frame.size.width = width;
    self.frame = frame;
}

- (CGFloat)width
{
    return self.frame.size.width;
}

- (void)setHeight:(CGFloat)height
{
    CGRect frame = self.frame;
    frame.size.height = height;
    self.frame = frame;
}

- (CGFloat)height
{
    return self.frame.size.height;
}

- (void)setSize:(CGSize)size
{
    self.width = size.width;
    self.height = size.height;
}

- (CGSize)size
{
    return self.frame.size;
}

- (CGFloat)maxX
{
    //    return self.x + self.width;
    return CGRectGetMaxX(self.frame);
}

- (CGFloat)maxY
{
//    return self.y + self.height;
    return CGRectGetMaxY(self.frame);
}

//移除子视图
- (void)removeAllSubViews {
    for (UIView *subView in self.subviews) {
        [subView removeFromSuperview];
    }
}

//
- (void)customCornerRadius:(CGFloat)radius {
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = radius;
}

//
- (void)customBorderColor:(UIColor *)color {
    self.layer.borderWidth = 0.5f;
    self.layer.borderColor = color.CGColor;
}

//根据高度适配屏幕
- (void)resetViewFrameWithHeight:(CGFloat)height {
    CGRect selfFrame = self.frame;
    selfFrame.size.height = height;
    self.frame = selfFrame;
}


@end
